package com.welsy.authoring.vo.course
{
	import com.welsy.authoring.business.ClosingTestElement;
	import com.welsy.authoring.vo.course.pattern.*;
	
	[Bindable]	
	public class TestComponents extends CourseItem 
	{
	  public var test:TestVO = new TestVO;
      
      private var _items:Array;

      public function TestComponents() {
         _items = new Array();
      }

      override public function addItem(item:ICourseItem):void {
         _items.push(item);
      }

      override public function removeItem(item:ICourseItem):void {
         var i:uint;
         // Loop through all the child elements.
         for(i = 0; i < _items.length; i++) {
            // If one of the elements matches the 
            // parameter remove it from the array.
            if(_items[i] == item) {
               _items.splice(i, 1);
               break;
            }
         }
      }
      
      public function removeAllItems():void {
      	//empty items array 
      	_items = new Array(0);
      }
      
      override public function iterator():ICourseIterator {    
      	     
         return new ArrayCourseIterator(_items);
      }
	  
	  public function getCollection():Array {         
         return _items;
      }
      
      public function setTest(cte:ClosingTestElement):void {
      	test.consultationTimeLimit = cte.consultationTimeLimit;
      	test.displayCorrectAnswere = cte.displayCorrectAnswere;
      	test.displayCorrected = cte.displayCorrected;
      	test.displayFeedback = cte.displayFeedback;
      	test.passingCondition = cte.passingCondition;
      	test.questionWeightType = cte.questionWeightType;
      	test.skipType = cte.skipType;
      	test.traceConsultationTime = cte.traceConsultationTime;
      	test.testId = cte.element.testID;
      	test.title = cte.element.title;      	
      }
      
	}
}